package zxing.activity.adapter;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;

import io.virtualapp.R;
import zxing.activity.bean.BackgBean;

/********************
 *  Created by ：  lyq 
 *         Date：  2018\11\15 0015.
 * Introduction：   
 *********************/

public class BackgAdapter extends BaseQuickAdapter<BackgBean.DataBean, BaseViewHolder> {
    private int selectPos = 0;

    public BackgAdapter(int layoutResId, @Nullable List<BackgBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BackgBean.DataBean item) {
        helper.addOnClickListener(R.id.relativ_p);
        helper.setText(R.id.text_name, item.getNameX());
        ImageView logoview = helper.getView(R.id.img_bg);
        Glide.with(mContext)
                .load(Uri.parse(item.getImgurl()))
                .into(logoview);
        helper.setTag(R.id.relativ_p, item.getImgurl());
        if (selectPos == helper.getAdapterPosition()) {
            helper.getView(R.id.img_select).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.img_select).setVisibility(View.GONE);
        }
    }

    public void setSelectPos(int pos) {
        this.selectPos = pos;
        notifyDataSetChanged();
    }


}
